<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags"  prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'update_role.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css"
			href="./styles/control_panel.css" />
	<script type="text/javascript">
		function callBack(){
			window.history.back();
		}
	</script>
	 <jsp:include page="../../rapid-validation.jsp"></jsp:include>
	 <script type="text/javascript">
	var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
function validateRole() {  
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    var roleName = document.getElementById("roleName").value;
    var idValue = document.getElementById("idValue").value;
    var url =  "bbs/role/role_validateUpdateData.action?time=" + new Date().getTime() + "&role=" + roleName+"&id="+idValue;
    xmlHttp.open("post", url, true);
    xmlHttp.setRequestHeader("content-type",
				"application/x-www-form-urlencoded;charset=utf-8");
    xmlHttp.send(null);
}    
function handleStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
           var doc = xmlHttp.responseText;
           var menuNameError = document.getElementById("roleNameError");
           	menuNameError.innerHTML = doc;
          		 }
        }
}

function testRole(){
	var roleNameError = document.getElementById("roleNameError");
	if(roleNameError.firstChild.getAttribute("color")=="#ff0000"){
		alert("角色名已存在，请修改后再提交");
		return false;
	}else{
		return true;
	}
	
}
</script>
  </head>
  
  <body>
    <div style="margin-bottom: 4px; margin-left: 12px;" align="center">
		<div
			style="border: 1px solid #cccccc; height: auto !important; height: 100px; min-height: 100px;">
			<div class="control_con_right_0021">
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td align="left" class="tb_left" valign="middle" colspan="3"
							style="padding-left: 10px;">
							修改角色信息
						</td>
					</tr>
				</table>
			</div>
    <form action="/OneSecSys/bbs/role/role_updateRole.action" method="post" id="form1" name="form1" onsubmit="if(!testRole()){return false;}">
    <table  cellpadding="0" cellspacing="0" width="100%">
    	<tr height="40px">
    		<td align="right" >角色名称：</td>
    		<td align="left">
    			<input type="text" name="roleDto.role" value="<s:property value="%{roleDto.role}"/>" onblur="validateRole();" class="required" id="roleName"/><font color="red">*</font> <span id="roleNameError"></span>
    			<input type="hidden" name="roleDto.id" value="<s:property value="%{roleDto.id}"/>" id="idValue"/>
    		</td>
    	</tr>
    	<tr>
    		<td align="right">角色状态：</td>
    		<td align="left" valign="top" ><s:select list="#{' ':'请选择','SOA':'有效','SOX':'无效'}" value="%{roleDto.statue}" name="roleDto.statue" theme="simple" cssClass="validate-selection"></s:select><font color="red">*</font> </td>
    	</tr>
    	<tr>
    		<td align="right">备注：</td>
    		<td align="left">
    			<s:textarea theme="simple" rows="5" cssClass="max-length-200" value="%{roleDto.remark}" name="roleDto.remark"></s:textarea>
    		</td>
    	</tr>
    	<tr height="20px"><td> </td><td> </td></tr>
    	<tr>
    		<td  align="right">
    			<input type="submit" value="修改" />&nbsp;&nbsp;
			</td>
			<td align="left">
				&nbsp;&nbsp;<input type="button" value="返回" onclick="callBack();">
    		</td>
    	</tr>
    </table>
    </form>
    </div>
    </div>
    <script>
new Validation('form1', {
	immediate : true
});
</script>
  </body>
</html>
